<!--
 * @Descripttion: 
 * @Version: 1.0
 * @Author: 何志龙
 * @Date: 2023-11-01 11:08:36
 * @LastEditors: 何志龙
 * @LastEditTime: 2023-11-01 11:40:46
-->
<template>
  <div class="bigData">
    <!-- <p class="subTitle"><span class="line"></span> <span style="color: #3f8ffc">大数据接口查询信息</span></p> -->
    <van-collapse v-model="activeNames1">
      <van-collapse-item name="1">
        <template #title>
          <p class="subTitle"><span class="line"></span> <span style="color: #3f8ffc">大数据接口查询信息</span></p>
        </template>
        <van-collapse v-model="activeNames" v-for="(item, index) in zgData" :key="index" :style="{ position: item.title == '家庭成员信息' ? 'relative' : '' }">
          <van-collapse-item :title="item.title" :name="index">
            <el-table size="small" :data="item.tableData" border style="width: 100%">
              <el-table-column v-for="(it, in1) in item.tablecoums" :key="in1" :prop="it.prop" :label="it.name" align="center">
                <template slot-scope="scope">
                  <p v-if="item.title == '家庭成员信息' && it.name == '与户主关系'" class="scopeItem">
                    {{
                      scope.row.YHZGX == '156'
                        ? '户主'
                        : scope.row.YHZGX == '267'
                        ? '孙女'
                        : scope.row.YHZGX == '28'
                        ? '夫妻'
                        : scope.row.YHZGX == '30'
                        ? '长子'
                        : scope.row.YHZGX == '166'
                        ? '次子'
                        : scope.row.YHZGX == '167'
                        ? '孙子'
                        : scope.row.YHZGX == '168'
                        ? '次女'
                        : scope.row.YHZGX == '169'
                        ? '长女'
                        : '其他亲属'
                    }}
                  </p>
                  <p v-if="it.name == '是否村集体股东'" class="scopeItem">
                    {{ scope.row.IFCJTGD ? (scope.row.IFCJTGD == '5' ? '是' : '否') : '' }}
                  </p>
                  <p v-else-if="it.name == '是否机关事业单位'" class="scopeItem">
                    {{ scope.row.IFJGSYDW ? (scope.row.IFJGSYDW == '5' ? '是' : '否') : '' }}
                  </p>
                  <p v-else-if="it.name == '婚姻状况'" class="scopeItem">
                    {{ scope.row.HYZK ? (scope.row.HYZK == '7' ? '已婚' : scope.row.HYZK == '8' ? '未婚' : '离婚') : '' }}
                  </p>
                  <p v-else-if="it.name == '是否有不动产'" class="scopeItem">
                    {{ scope.row.IFBDC ? (scope.row.IFBDC == '5' ? '是' : '否') : '' }}
                  </p>
                  <p v-else-if="item.title == '家庭成员信息' && it.name == '性别'" class="scopeItem">
                    {{ scope.row.SEX == '3' ? '男' : '女' }}
                  </p>
                  <p v-else-if="item.title == '家庭成员信息' && it.name != '与户主关系'">
                    {{ scope.row[it.prop] }}
                  </p>
                </template>
              </el-table-column>
            </el-table>
          </van-collapse-item>
        </van-collapse>
      </van-collapse-item>
    </van-collapse>
  </div>
</template>

<script>
import { FileServerProxy, housebigDataForUser } from '@/utils/api'
export default {
  data() {
    return {
      activeNames: ['0'],
      activeNames1: ['0'],
      zgData: [
        {
          title: '户籍家庭成员信息',
          tableData: [],
          tablecoums: [
            {
              name: '姓名',
              prop: 'FAMILYNAME'
            },
            {
              name: '年龄',
              prop: 'FAMILYAGE'
            },
            {
              name: '与户主关系',
              prop: 'HOUSERELATIONSHIP'
            },
            {
              name: '身份证号',
              prop: 'FAMILYIDCARD'
            },
            {
              name: '性别',
              prop: 'FAMILYSEX'
            },
            {
              name: '出生日期',
              prop: 'HOUSEBIRTHDAY'
            },
            {
              name: '是否村集体股东',
              prop: 'IFCJTGD'
            },
            {
              name: '婚姻状况',
              prop: 'HOUSEMERRIAGE'
            },
            {
              name: '是否有不动产',
              prop: 'IFBDC'
            },
            {
              name: '是否机关事业单位',
              prop: 'YHZGX'
            },
            {
              name: '不动产编号',
              prop: 'BDCBH'
            },
            {
              name: '死亡时间',
              prop: 'SWSJ'
            },
            {
              name: '火化时间',
              prop: 'HHSJ'
            }
          ]
        },
        {
          title: '村集体股东信息',
          tableData: [],
          tablecoums: [
            {
              name: '姓名',
              prop: 'name'
            },
            {
              name: '性别',
              prop: 'sex'
            },
            {
              name: '身份证号',
              prop: 'SFZH'
            },
            {
              name: '与户主关系',
              prop: 'houserelationship'
            },
            {
              name: '是否村集体股东',
              prop: 'iscollective'
            },
            {
              name: '村集体股东描述',
              prop: 'collectivediscripe'
            }
          ]
        },
        {
          title: '婚姻信息',
          tableData: [],
          tablecoums: [
            {
              name: '姓名',
              prop: 'FAMILYNAME'
            },
            {
              name: '婚姻状况',
              prop: 'MERRIAGECONDITION'
            },
            {
              name: '婚姻描述',
              prop: 'MERRIAGEDISCRIBE'
            }
          ]
        },
        {
          title: '不动产权信息',
          tableData: [],
          tablecoums: [
            {
              name: '姓名',
              prop: 'FAMILYNAME'
            },
            {
              name: '是否有不动产',
              prop: 'ISREALESTATE'
            },
            {
              name: '不动产编号',
              prop: 'REALESTATENUMBER'
            },
            {
              name: '不动产权证描述',
              prop: 'REALESTATEDISCRIBE'
            }
          ]
        },
        {
          title: '机关事业单位',
          tableData: [],
          tablecoums: [
            {
              name: '姓名',
              prop: 'FAMILYNAME'
            },
            {
              name: '是否机关事业单位',
              prop: 'ISORGANS'
            },
            {
              name: '机关事业单位描述',
              prop: 'ORGANSDISCRIBE'
            }
          ]
        },
        {
          title: '火化信息',
          tableData: [],
          tablecoums: [
            {
              name: '姓名',
              prop: 'XM'
            },
            {
              name: '民族',
              prop: 'MZ'
            },
            {
              name: '地址',
              prop: 'DZ'
            },
            {
              name: '死亡时间',
              prop: 'SWSJ'
            },
            {
              name: '火化时间',
              prop: 'HHSJ'
            }
          ]
        }
      ],
      multipleSelection10: []
    }
  },
  props: {
    CERTIFICATECODE: {
      typeof: 'string',
      default: '1111'
    },
    HOUSEAPPLICANT: {
      typeof: 'string',
      default: '1111'
    },
    sex: {
      typeof: 'string',
      default: '女'
    },
    CUN: {
      typeof: 'string',
      default: '3306'
    }
  },
  methods: {
    getTableData: async function (idname, userName, sex, cityCode) {
      let params = {
        idCardNum: idname,
        userName: userName,
        sex: sex,
        cityCode: cityCode
      }
      const res = await housebigDataForUser(params)
      let newobj = res.data.data
      for (let key in newobj) {
        if (key == 'accumulationFund' && newobj[key]) {
          newobj[key].forEach((item) => {
            if (item.zrzhzt == '9') {
              //当zrzhzt  =  9 时 渲染
            } else {
              this.zgData.forEach((item) => {
                if (item.title == '机关事业单位' && newobj[key] !== null) {
                  newobj[key].forEach((items, index) => {
                    item.tableData[index] = {}
                    for (let k in items) {
                      switch (k) {
                        case 'xingming':
                          item.tableData[index].FAMILYNAME = items[k]
                          break
                        case 'zrzhzt':
                          item.tableData[index].ISORGANS = items[k] == '3' ? '6' : '5'
                          break
                        case 'dwmc':
                          item.tableData[index].ORGANSDISCRIBE = items[k]
                          break
                      }
                    }
                  })
                }
              })
            }
          })
        } else if (key == 'cremationInfo' && newobj[key]) {
          //火化信息
          this.zgData.forEach((item) => {
            if (item.title == '火化信息' && newobj[key] !== null) {
              newobj[key].forEach((items, index) => {
                item.tableData[index] = {}
                for (let k in items.ELC_LICENCE_STRUCT.DATA) {
                  switch (k) {
                    case 'DURNAME':
                      item.tableData[index].XM = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                    case 'DURNATION':
                      item.tableData[index].MZ = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                    case 'DURHOUSEHOLD':
                      item.tableData[index].DZ = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                    case 'DURDEATHDATE':
                      item.tableData[index].SWSJ = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                    case 'DURINTERVAL':
                      item.tableData[index].HHSJ = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                  }
                }
              })
            }
          })
        } else if (key == 'marriageInfo' && newobj[key]) {
          //婚姻信息
          this.zgData.forEach((item) => {
            if (item.title == '婚姻信息' && newobj[key] !== null) {
              newobj[key].forEach((items, index) => {
                item.tableData[index] = {}
                for (let k in items) {
                  switch (k) {
                    case 'fName':
                      item.tableData[index].FAMILYNAME = items[k]
                      break
                    case 'businessType':
                      item.tableData[index].MERRIAGECONDITION = items[k] == '结婚登记' ? '7' : '8'
                      break
                    case 'system_note':
                      item.tableData[index].MERRIAGEDISCRIBE = items[k]
                      break
                  }
                }
              })
            }
          })
        } else if (key == 'realEstateCertificate' && newobj[key]) {
          //不动产信息
          this.zgData.forEach((item) => {
            if (item.title == '不动产权信息' && newobj[key] !== null) {
              newobj[key].forEach((items, index) => {
                item.tableData[index] = {}
                for (let k in items.ELC_LICENCE_STRUCT.DATA) {
                  switch (k) {
                    case 'QLR':
                      item.tableData[index].FAMILYNAME = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                    case 'ZSGBH':
                      item.tableData[index].REALESTATENUMBER = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                    case 'QLQTZK':
                      item.tableData[index].REALESTATEDISCRIBE = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                  }
                }
              })
            }
          })
        } else if (key == 'residenceBooklet' && newobj[key]) {
          //户籍家庭信息
          this.zgData.forEach((item) => {
            if (item.title == '户籍家庭成员信息' && newobj[key] !== null) {
              newobj[key].forEach((items, index) => {
                item.tableData[index] = {}
                for (let k in items.ELC_LICENCE_STRUCT.DATA) {
                  switch (k) {
                    case 'CZRKYHZGX':
                      item.tableData[index].HOUSERELATIONSHIP = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                    case 'CZRKXM':
                      item.tableData[index].FAMILYNAME = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                    case 'CZRKHYZK':
                      item.tableData[index].HOUSEMERRIAGE = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                    case 'CZRKXB':
                      item.tableData[index].FAMILYSEX = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                    case 'CZRKGMSFHM':
                      item.tableData[index].FAMILYIDCARD = items.ELC_LICENCE_STRUCT.DATA[k]
                      item.tableData[index].FAMILYAGE = idCard(items.ELC_LICENCE_STRUCT.DATA[k], 3)
                      item.tableData[index].HOUSEBIRTHDAY = idCard(items.ELC_LICENCE_STRUCT.DATA[k], 1)
                      break
                    case 'CZRKYHZGX':
                      item.tableData[index].YHZGX = items.ELC_LICENCE_STRUCT.DATA[k]
                      break
                  }
                }
              })
            }
          })
        } else if (key == 'villageCollectiveShareholders') {
          //村集体股东
        }
      }
    }
  },
  created() {
    // this.getTableData(this.CERTIFICATECODE, this.HOUSEAPPLICANT, this.sex == '女' ? 'W' : 'M', this.CUN)
  }
}
</script>

<style lang="scss">
.bigData .van-collapse-item__content {
  padding: 0px;
  color: black;
}
.bigData .el-table th.el-table__cell > .cell {
  color: black;
}
.bigData .subTitle {
  width: 100%;
  // height: 40px;
  // line-height: 40px;
  font-size: 14px;
  position: relative;
  display: flex;
  align-items: center;
  // border-bottom: 1px solid #9b9b9b;
  // padding-left: 4px;

  .line {
    width: 6px;
    height: 26px;
    background: #3f8ffc;
    display: inline-block;
    margin-right: 10px;
  }
   
}
</style>

<style>
.van-collapse-item__title {
    border-bottom: 1px solid #9b9b9b;
}
</style>
